<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Centos7上搭建Lnmp&#43;Ghost 1.x博客 - Feng&#39;s Blog - 大灰鼠的博客</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="Feng" /><meta name="description" content="上次写过《Debian 8.X搭建Lnmp&#43; Ghost 1.x 教程》 ，这不将主机从香港搬回到大杭州后，域名又倒腾回之前的uu126.cn（当然加了个前缀bl" /><meta name="keywords" content="feng, 折腾人生, 电脑维修, 手机玩转, 技术心得, 拆机, 网站建设, 快乐悠悠, uu, 悠悠, 博客" />






<meta name="generator" content="Hugo 0.76.5 with theme even" />


<link rel="canonical" href="https://uu126.gitee.io/2017/387.html" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">



<link href="/sass/main.min.c7bc1becf36bcf6a9ebd25d2947e43a2eb745ddb0c9a32b43126fd7fa460c351.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="Centos7上搭建Lnmp&#43;Ghost 1.x博客" />
<meta property="og:description" content="上次写过《Debian 8.X搭建Lnmp&#43; Ghost 1.x 教程》 ，这不将主机从香港搬回到大杭州后，域名又倒腾回之前的uu126.cn（当然加了个前缀bl" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://uu126.gitee.io/2017/387.html" />
<meta property="article:published_time" content="2017-11-02T21:15:00+00:00" />
<meta property="article:modified_time" content="2017-11-02T21:15:00+00:00" />
<meta itemprop="name" content="Centos7上搭建Lnmp&#43;Ghost 1.x博客">
<meta itemprop="description" content="上次写过《Debian 8.X搭建Lnmp&#43; Ghost 1.x 教程》 ，这不将主机从香港搬回到大杭州后，域名又倒腾回之前的uu126.cn（当然加了个前缀bl">
<meta itemprop="datePublished" content="2017-11-02T21:15:00+00:00" />
<meta itemprop="dateModified" content="2017-11-02T21:15:00+00:00" />
<meta itemprop="wordCount" content="1019">



<meta itemprop="keywords" content="Ghost," />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Centos7上搭建Lnmp&#43;Ghost 1.x博客"/>
<meta name="twitter:description" content="上次写过《Debian 8.X搭建Lnmp&#43; Ghost 1.x 教程》 ，这不将主机从香港搬回到大杭州后，域名又倒腾回之前的uu126.cn（当然加了个前缀bl"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">Feng&#39;s Blog</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">Home</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">Archives</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/links/">
        <li class="mobile-menu-item">Links</li>
      </a><a href="/ly/">
        <li class="mobile-menu-item">Ly</li>
      </a><a href="/about/">
        <li class="mobile-menu-item">About</li>
      </a>
  </ul>
</nav>
  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">Feng&#39;s Blog</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">Home</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">Archives</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">Tags</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/links/">Links</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/ly/">Ly</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/about/">About</a>
      </li>
  </ul>
</nav>
    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">Centos7上搭建Lnmp&#43;Ghost 1.x博客</h1>

      <div class="post-meta">
        <span class="post-time"> 2017-11-02 </span>
        <div class="post-category">
            <a href="/categories/%E7%BD%91%E7%AB%99%E5%BB%BA%E8%AE%BE/"> 网站建设 </a>
            </div>
          <span class="more-meta"> 约 1019 字 </span>
          <span class="more-meta"> 预计阅读 3 分钟 </span>
        
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents"></nav>
  </div>
</div>
    <div class="post-content">
      <p>上次写过<a href="https://blog.uu126.cn/debian-8-8da-jian-lnmp-ghost-1-x-jiao-cheng/" target="_blank"  rel="nofollow" >《Debian 8.X搭建Lnmp+ Ghost 1.x 教程》</a> ，这不将主机从香港搬回到大杭州后，域名又倒腾回之前的uu126.cn（当然加了个前缀blog），加上前不久刚好在<a href="http://blog.imzhengfei.com/centos-7-an-zhuang-pei-zhi-ghost-1-x/" target="_blank"  rel="nofollow" >海月博客</a> ，顺手也尝试了一下Centos，结果一切搭建顺利，又可以让我啰嗦一下了。</p>
<ol>
<li>
<p>Lnmp的搭建就不细说了，可以参照我之前的博文（点击：<a href="https://blog.uu126.cn/debian-8-8da-jian-lnmp-ghost-1-x-jiao-cheng/" target="_blank"  rel="nofollow" >传送门</a> ），这里还是推荐使用Oneinstack，相对功能多一点。搭建好以后，使用PHPmyadmin创建所需的博客数据库用户名、数据库（用这个创建较方便），另外也可以直接配置好站点的Nginx文件和SSL，这里就不在啰嗦了，有问题的亲，可以留言。</p>
</li>
<li>
<p>安装 Node.js</p>
<ul>
<li>方法一：</li>
</ul>
</li>
</ol>
<pre><code>curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install nodejs
</code></pre>
<ul>
<li>
<p>方法二（推荐使用）：</p>
<p>国外下载地址：
wget <a href="https://nodejs.org/download/release/v6.9.5/node-v6.9.5.tar.gz">https://nodejs.org/download/release/v6.9.5/node-v6.9.5.tar.gz</a>
国内下载地址：
wget <a href="https://npm.taobao.org/mirrors/node/v6.9.5/node-v6.9.5.tar.gz">https://npm.taobao.org/mirrors/node/v6.9.5/node-v6.9.5.tar.gz</a>
tar zxvf node-v6.9.5.tar.gz
cd node-v6.9.5
./configure
make &amp;&amp; make install</p>
</li>
</ul>
<p>安装好之后可以使用 <code>node -v</code> 查看，能看到版本号一般就OK了。</p>
<ol>
<li>配置 Yarn<br>
可选，使用 yarn 代替 npm，更加快速，安全，稳定。</li>
</ol>
<pre><code>wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
yum -y install yarn
</code></pre>
<p>同样安装之后可以使用 <code>yarn -v</code> 查看，看到版本号就行。</p>
<ul>
<li>
<p>查看 npm 全局生成可执行文件软链的路径：</p>
<p>npm -g bin</p>
</li>
</ul>
<blockquote>
<p>/usr/bin</p>
</blockquote>
<ul>
<li>
<p>查看 yarn 全局生成可执行文件软链的路径：</p>
<p>yarn global bin</p>
</li>
</ul>
<blockquote>
<p>/usr/local/bin</p>
</blockquote>
<p>修改 yarn 全局生成可执行文件软链的路径和 npm 保持一致：</p>
<pre><code>yarn config set prefix /usr
</code></pre>
<blockquote>
<p>yarn config v1.2.1<br>
success Set &ldquo;prefix&rdquo; to &ldquo;/usr&rdquo;.<br>
Done in 0.03s.</p>
</blockquote>
<p>再次查看 yarn 全局生成可执行文件软链的路径：</p>
<pre><code>yarn global bin
</code></pre>
<blockquote>
<p>/usr/bin</p>
</blockquote>
<ol>
<li>安装 Ghost-CLI<br>
使用 yarn 全局安装 ghost-cli：</li>
</ol>
<pre><code>yarn global add ghost-cli
</code></pre>
<p>查看安装的 ghost-cli 版本：</p>
<pre><code>ghost -v
</code></pre>
<blockquote>
<p>Ghost-CLI version: 1.1.3</p>
</blockquote>
<ol>
<li>安装Ghost1.X<br>
创建网站目录：</li>
</ol>
<pre><code>mkdir -p /home/wwwroot/blog.uu126.cn
</code></pre>
<p>进入到网站目录：</p>
<pre><code>cd /home/wwwroot/blog.uu126.cn
</code></pre>
<p>在当前目录免配置安装 ghost：</p>
<pre><code>ghost install --no-setup
</code></pre>
<blockquote>
<p>✔ Checking system Node.js version<br>
✔ Checking current folder permissions<br>
System checks failed with message: &lsquo;Linux version is not Ubuntu 16&rsquo;<br>
Some features of Ghost-CLI may not work without additional configuration.<br>
For local installs we recommend using ghost install local instead.<br>
? Continue anyway?</p>
</blockquote>
<p>输入 <code>y</code> ，回车：</p>
<blockquote>
<p>? Continue anyway? Yes<br>
✔ Checking operating system<br>
✔ Checking MySQL is installed<br>
✔ Checking for latest Ghost version<br>
✔ Setting up install directory<br>
✔ Downloading and installing Ghost v1.16.0<br>
✔ Finishing install process</p>
</blockquote>
<ol>
<li>
<p>配置Ghost1.x</p>
<ul>
<li>使用 ghost-ci 配置 ghost：</li>
</ul>
</li>
</ol>
<pre><code>ghost config
</code></pre>
<blockquote>
<p>? Enter your blog URL: (<a href="http://localhost" target="_blank"  rel="nofollow" >http://localhost</a>:2368)</p>
</blockquote>
<p>输入自己网站完整访问路径 <code>http://blog.uu126.cn</code> 回车：</p>
<blockquote>
<p>? Enter your blog URL: <a href="http://blog.imzhengfei.com" target="_blank"  rel="nofollow" ><a href="http://blog.imzhengfei.com">http://blog.imzhengfei.com</a></a><br>
? Enter your MySQL hostname: (localhost)</p>
</blockquote>
<p>输入 MySQL 主机地址，如果在本机直接回车：</p>
<blockquote>
<p>? Enter your MySQL hostname: localhost<br>
? Enter your MySQL username:</p>
</blockquote>
<p>输入上面创建的 MySQL 用户名，密码，数据库名称：</p>
<blockquote>
<p>? Enter your MySQL username: ghost<br>
? Enter your MySQL password: [hidden]<br>
? Enter your Ghost database name: ghost</p>
</blockquote>
<ul>
<li>初始化数据库</li>
</ul>
<p>使用 ghost-ci 初始化数据库：</p>
<pre><code>ghost setup migrate
</code></pre>
<blockquote>
<p>✔ Running database migrations</p>
</blockquote>
<ul>
<li>配置系统用户</li>
</ul>
<p>使用 ghost-ci 添加 ghost 用户来运行 ghost：</p>
<pre><code>ghost setup linux-user
</code></pre>
<blockquote>
<p>Running sudo command: useradd &ndash;system &ndash;user-group ghost<br>
Running sudo command: chown -R ghost:ghost /home/wwwroot/blog.imzhengfei.com/content<br>
✔ Setting up &ldquo;ghost&rdquo; system user</p>
</blockquote>
<ul>
<li>配置系统服务</li>
</ul>
<p>使用 ghost-ci 创建系统服务：</p>
<pre><code>ghost setup systemd
</code></pre>
<blockquote>
<p>Running sudo command: ln -sf &gt;/home/wwwroot/blog.uu126.cn/system/files/ghost_undefined.service &gt;/lib/systemd/system/ghost_undefined.service<br>
Running sudo command: systemctl daemon-reload<br>
✔ Setting up Systemd</p>
</blockquote>
<ol>
<li>
<p>测试访问博客</p>
<ul>
<li>使用 ghost-ci 启动当前网站：</li>
</ul>
</li>
</ol>
<pre><code>ghost start
</code></pre>
<blockquote>
<p>✔ Validating config<br>
Running sudo command: systemctl start ghost_undefined<br>
✔ Starting Ghost<br>
Running sudo command: systemctl enable ghost_undefined &ndash;quiet<br>
✔ Starting Ghost<br>
You can access your blog at <a href="http://blog.uu126.cn" target="_blank"  rel="nofollow" ><a href="http://blog.uu126.cn">http://blog.uu126.cn</a></a><br>
Ghost uses direct mail by default<br>
To set up an alternative email method read our docs at <a href="https://docs.ghost.org/docs/mail-config" target="_blank"  rel="nofollow" ><a href="https://docs.ghost.org/docs/mail-config">https://docs.ghost.org/docs/mail-config</a></a></p>
</blockquote>
<ul>
<li>尝试访问自己的博客。</li>
</ul>
<p>注册管理员账户**（ domain 是自己的博客域名）**：</p>
<pre><code>http:///ghost</code></pre>

    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">Feng</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2017-11-02
        
    </span>
  </p>
  
  
</div>
<div class="post-reward">
  <input type="checkbox" name="reward" id="reward" hidden />
  <label class="reward-button" for="reward">赞赏支持</label>
  <div class="qr-code">
    
    <label class="qr-code-image" for="reward">
        <img class="image" src="https://cdn.uu126.cn/hugo/wechat.png">
        <span>微信打赏</span>
      </label>
    <label class="qr-code-image" for="reward">
        <img class="image" src="https://cdn.uu126.cn/hugo/alipay.png">
        <span>支付宝打赏</span>
      </label>
  </div>
</div><footer class="post-footer">
      <div class="post-tags">
          <a href="/tags/ghost/">Ghost</a>
          </div>
      <nav class="post-nav">
        <a class="prev" href="/2018/388.html">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">2018，我来了</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="/2017/386.html">
            <span class="next-text nav-default">再见，我的长假</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        

  
  <div id="vcomments"></div>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>
  <script type="text/javascript">
    new Valine({
        el: '#vcomments' ,
        appId: '5sMkTX4FLjetFnfbOhaDTCDJ-9Nh9j0Va',
        appKey: '25KXCqIqAN142RQn4fBrsI87',
        notify:  false ,
        verify:  false ,
        avatar:'mm',
        placeholder: '说点什么吧...',
        visitor:  false 
    });
  </script>

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
  <a href="https://uu126.gitee.io/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="copyright-year">  
  Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a> + <a href="https://cloud.tencent.com/redirect.php?redirect=1005&cps_key=4e78216aea817227ff0c96d93a00fd4b" target="_blank" rel="nofollow">腾讯云 + </a><a href="https://console.upyun.com/register/?invite=S1JeTquHL" target="_blank" rel="nofollow"><span class="with-love"><img src="https://cdn.lancn.cn/images/upyun.png" style="width:45px;vertical-align:middle;" alt="又拍云存储"></span></a>
   </span> 
  <div class="busuanzi-footer">
    <a target="_blank"  href="http://www.beian.miit.gov.cn">浙ICP备11026647号-3</a><span class="post-meta-divider"> | </span><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33088102001325"><span class="with-love"><img src="https://cdn.uu126.cn/icon-police.png" style="width:14px;"></span> 浙公网安备33088102001325号</a>
  </div>
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>
   

  

  <span class="copyright-year">
    &copy; 
    2012 - 
    2020<span class="heart"><i class="iconfont icon-heart"></i></span><span>Feng</span>
  </span>
</div>

    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  <script src="/lib/highlight/highlight.pack.js?v=20171001"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>



<script type="text/javascript" src="/js/main.min.c12618f9a600c40bd024996677e951e64d3487006775aeb22e200c990006c5c7.js"></script>








</body>
</html>
